import algorithm.*;
import com.sun.org.apache.xalan.internal.xsltc.dom.CurrentNodeListFilter;
import dataset.CustomizedDataset;
import performance.inner.InnerPerformanceMeasure;
import performance.outer.OuterPerformanceMeasure;
import util.CsvUtils;

import java.util.Date;
import java.util.List;

public class test {
    public static void main(String[] args) throws InterruptedException {
//        long a = System.currentTimeMillis();
//        Thread.sleep(300);
//        long b = System.currentTimeMillis();
//        System.out.println(b-a);
        List<List<String>> lists = CsvUtils.csvToList("/Users/liyuanqing/IdeaProjects/cluster-algorithm/src/main/java/set/xigua.csv", ",");
//        CustomizedDataset ds = new CustomizedDataset(lists, 2,0);
//        LVQ lvq = (LVQ) new ClusterFactory().create(ClusterFactory.LVQ);
//        System.out.println(lvq.fit(ds));
//        for (int i : lvq.result.label) {
//            System.out.print(i+",");
//        }

        CustomizedDataset ds = new CustomizedDataset(lists, 0);
        ds.label = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0};
        LVQ lvq = (LVQ) new ClusterFactory().create(ClusterFactory.LVQ);
        lvq.setT(200);
        lvq.setEta(0.1);
        lvq.setT(0, 1, 1, 0, 0);
        lvq.fit(ds);
//        for (int i : ds.label) {
//            System.out.print(i + " ");
//        }
        System.out.print("[");
        boolean isFirst = true;
        for (int i : lvq.result.label) {
            if (!isFirst)
                System.out.print(", ");
            isFirst = false;
            System.out.print(i);
        }
//        System.out.println();
//        DAKMeans dakMeans = (DAKMeans) new ClusterFactory().create(ClusterFactory.DAKMEANS);
//        dakMeans.setK(2);
//        dakMeans.setLinkage(Linkage.AVERAGE_LINKAGE);
//        dakMeans.setMinPts(5);
//        dakMeans.setEpsilon(0.11);
//        System.out.println(dakMeans.fit(ds));
//        System.out.print("[");
//        boolean isFirst = true;
//        for (int i : dakMeans.result.label) {
//            if (!isFirst)
//                System.out.print(", ");
//            isFirst = false;
//            System.out.print(i);
//        }
//        System.out.println("]");
//        OuterPerformanceMeasure outerPerformanceMeasure = new OuterPerformanceMeasure(dakMeans.result.label, ds);
//        System.out.println(outerPerformanceMeasure.measures());
//        InnerPerformanceMeasure innerPerformanceMeasure = new InnerPerformanceMeasure(dakMeans.result);
//        System.out.println(innerPerformanceMeasure.measures());
//        System.out.println();
//        InnerPerformanceMeasure innerPerformanceMeasure = new InnerPerformanceMeasure(dak.result);
//        System.out.println(innerPerformanceMeasure.measures());

//        KMeans kMeans = (KMeans) new ClusterFactory().create(ClusterFactory.KMEANS);
//        kMeans.setK(2);
//        long time = kMeans.fit(ds);
//        System.out.println(time);
//        for (int i : kMeans.result.label) {
//            System.out.print(i + " ");
//        }
    }
}
